<template>
<div>
    <el-form :model="inputForm" ref="inputForm" v-loading="loading"   :disabled="formReadOnly"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="24">
            <el-form-item label="送修人工号" prop="sparepartsSendId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsSendId" placeholder="请填写送修人工号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="送修人姓名" prop="sparepartsSendName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsSendName" placeholder="请填写送修人姓名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="接收人工号" prop="sparepartsReceivcId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsReceivcId" placeholder="请填写接收人工号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="接收人姓名" prop="sparepartsReceiveName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsReceiveName" placeholder="请填写接收人姓名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="接收部门" prop="sparepartsReceivePart"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsReceivePart" placeholder="请填写接收部门"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="接受日期" prop="sparepartsReceiveDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsReceiveDate" placeholder="请填写接受日期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="报修说明" prop="sparepartsRepairsState"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsRepairsState" placeholder="请填写报修说明"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="报废说明" prop="sparepartsScrapState"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsScrapState" placeholder="请填写报废说明"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="待修说明" prop="sparepartsForRepairsState"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsForRepairsState" placeholder="请填写待修说明"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="物料编码" prop="sparepartsCoding"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsCoding" placeholder="请填写物料编码"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="物料名称" prop="sparepartsName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsName" placeholder="请填写物料名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="规格型号" prop="sparepartsType"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsType" placeholder="请填写规格型号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="计量单位" prop="sparepartsUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUnit" placeholder="请填写计量单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="使用单位" prop="sparepartsUseUnit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUseUnit" placeholder="请填写使用单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="ABC分类" prop="sparepartsAbcCategory"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsAbcCategory" placeholder="请填写ABC分类"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="上线日期" prop="sparepartsUpDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUpDate" placeholder="请填写上线日期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="下线日期" prop="sparepartsDownDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsDownDate" placeholder="请填写下线日期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="下线原因" prop="sparepartsUpReason"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUpReason" placeholder="请填写下线原因"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="单价" prop="sparepartsUnitCost"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUnitCost" placeholder="请填写单价"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="使用周期" prop="sparepartsUseCycle"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUseCycle" placeholder="请填写使用周期"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="处理人工号" prop="sparepartsDealId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsDealId" placeholder="请填写处理人工号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="处理人姓名" prop="sparepartsDealName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsDealName" placeholder="请填写处理人姓名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="登记时间" prop="sparepartsReginsterTime"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsReginsterTime" placeholder="请填写登记时间"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="登记人" prop="sparepartsPeople"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsPeople" placeholder="请填写登记人"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="处理方式" prop="sparepartsDealMethod"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsDealMethod" placeholder="请填写处理方式"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修方式" prop="sparepartsRepairMethod"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsRepairMethod" placeholder="请填写维修方式"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修人工号" prop="sparepartsRepairId"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsRepairId" placeholder="请填写维修人工号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修人姓名" prop="sparepartsRepairName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsRepairName" placeholder="请填写维修人姓名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修开始日" prop="sparepartsStartDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsStartDate" placeholder="请填写维修开始日"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修结束日" prop="sparepartsEndDate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsEndDate" placeholder="请填写维修结束日"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修工时" prop="sparepartsWorkTime"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsWorkTime" placeholder="请填写维修工时"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="维修状态" prop="sparepartsStatus"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsStatus" placeholder="请填写维修状态"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="报修说明" prop="sparepartsState"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsState" placeholder="请填写报修说明"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="物料编码" prop="sparepartsMaterialCoding"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsMaterialCoding" placeholder="请填写物料编码"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="物料名称" prop="sparepartsMaterialName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsMaterialName" placeholder="请填写物料名称"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="24">
            <el-form-item label="使用数量" prop="sparepartsUseCount"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sparepartsUseCount" placeholder="请填写使用数量"     ></el-input>
           </el-form-item>
        </el-col>
        </el-row>
    </el-form>
</div>
</template>

<script>
  export default {
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          id: '',
          sparepartsSendId: '',
          sparepartsSendName: '',
          sparepartsReceivcId: '',
          sparepartsReceiveName: '',
          sparepartsReceivePart: '',
          sparepartsReceiveDate: '',
          sparepartsRepairsState: '',
          sparepartsScrapState: '',
          sparepartsForRepairsState: '',
          sparepartsCoding: '',
          sparepartsName: '',
          sparepartsType: '',
          sparepartsUnit: '',
          sparepartsUseUnit: '',
          sparepartsAbcCategory: '',
          sparepartsUpDate: '',
          sparepartsDownDate: '',
          sparepartsUpReason: '',
          sparepartsUnitCost: '',
          sparepartsUseCycle: '',
          sparepartsDealId: '',
          sparepartsDealName: '',
          sparepartsReginsterTime: '',
          sparepartsPeople: '',
          sparepartsDealMethod: '',
          sparepartsRepairMethod: '',
          sparepartsRepairId: '',
          sparepartsRepairName: '',
          sparepartsStartDate: '',
          sparepartsEndDate: '',
          sparepartsWorkTime: '',
          sparepartsStatus: '',
          sparepartsState: '',
          sparepartsMaterialCoding: '',
          sparepartsMaterialName: '',
          sparepartsUseCount: ''
        }
      }
    },
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      }
    },
    components: {
    },
    watch: {
      'businessId': {
        handler (newVal) {
          if (this.businessId) {
            this.init(this.businessId)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        },
        immediate: true,
        deep: false
      }
    },
    methods: {
      init (id) {
        if (id) {
          this.loading = true
          this.inputForm.id = id
          this.$nextTick(() => {
            this.$refs.inputForm.resetFields()
            this.$http({
              url: `/spareparts/material/sparepartsDownFlow/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.sparepartsDownFlow)
              this.loading = false
            })
          })
        }
      },
      // 表单提交
      saveForm (callback) {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/spareparts/material/sparepartsDownFlow/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              if (data && data.success) {
                callback(data.businessTable, data.businessId)
              }
            })
          }
        })
      }
    }
  }
</script>